#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include <string>
using namespace std;
class Solution {
public:
    string addBinary(string a, string b)
    {
        string ret;
        int len1 = a.size() - 1, len2 = b.size() - 1, t = 0;;
        while (len1 >= 0 || len2 >= 0 || t)
        {
            if (len1 >= 0) t += a[len1--] - '0';
            if (len2 >= 0) t += b[len2--] - '0';
            ret += t % 2 + '0';
            t /= 2;
        }
        reverse(ret.begin(), ret.end());
        return ret;
    }
};